#ifndef NV_LOGGER
#define NV_LOGGER

#include <NvInfer.h>
#include <spdlog/spdlog.h>

namespace weilin {

class NvLogger : public nvinfer1::ILogger {
  void log(Severity severity, const char *msg) noexcept override {
    switch (severity) {
      case nvinfer1::ILogger::Severity::kINTERNAL_ERROR:
      case nvinfer1::ILogger::Severity::kERROR:
        spdlog::error(msg);
        break;
      case nvinfer1::ILogger::Severity::kWARNING:
        spdlog::warn(msg);
        break;
      case nvinfer1::ILogger::Severity::kINFO:
        spdlog::info(msg);
        break;
      case nvinfer1::ILogger::Severity::kVERBOSE:
        spdlog::debug(msg);
        break;
    }
  }
};

extern NvLogger nv_logger;

}  // namespace weilin

#endif  // !NV_LOGGER
